#include "stdafx.h"
#include "Random.h"

float mutil::random::uNorm()
{
	return rand() / (float)RAND_MAX;
}

float mutil::random::norm()
{
	return ( rand() / (float)RAND_MAX ) * 2 - 1;
}

float mutil::random::between( float min, float max )
{
	return min + uNorm() * (max - min);
}

XMVECTOR mutil::random::direction()
{
	XMVECTOR dir;
	float length;
	do 
	{
		dir = XMVectorSet(norm(), norm(), norm(), 0.0f);
		length = XMVectorGetX(XMVector3Length(dir));
	} while (length > 1);
	return XMVectorDivide(dir, XMVectorReplicate(length));
}
